var _o51;
var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2ConstValue = require("ConstValue");
var $2GameUser = require("GameUser");
var $2EventCenter = require("EventCenter");
var l = cc._decorator.ccclass;
var def_InterstitialMgr = _o51 = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this.interstitialAd = null;
    this.showing = false;
  }
  return babel_createClass(_ctor, [{
    key: "show",
    value: function show(e, t) {
      var _this48 = this;
      var n = new Date().getTime();
      console.log("11111111", n <= $2GameUser.default.getInstance().beforeSeeVideoTime);
      if (!(n <= $2GameUser.default.getInstance().beforeSeeVideoTime)) {
        if (window.wx.createInterstitialAd && null == this.interstitialAd) {
          this.interstitialAd = window.wx.createInterstitialAd({
            adUnitId: e
          }), this.interstitialAd.onLoad(function () {
            console.log("插屏 广告加载成功");
            t && t(true);
          }), this.interstitialAd.onError(function (e) {
            _this48.showing = false;
            t && t(false);
            console.log(e, "插屏 广告加载失败");
            $2EventCenter.default.postEvent("showButtons");
          }), this.interstitialAd.onClose(function (e) {
            _this48.showing = false;
            console.log(e, "插屏 广告关闭");
            $2EventCenter.default.postEvent("showButtons");
            $2GameUser.default.getInstance().beforeSeeVideoTime = 3e4 + new Date().getTime();
            console.log("插屏时间记录：", $2GameUser.default.getInstance().beforeSeeVideoTime);
            $2ConstValue.ConstValue.InterAdIntervalTime += $2ConstValue.ConstValue.INSERT_VIDEO_INTERVAL_WX;
            _this48.close();
          });
        }
        if (0 == this.showing) {
          this.showing = true, this.interstitialAd.show().then(function () {
            console.log("插屏 广告展示成功");
          }).catch(function (e) {
            _this48.showing = false;
            $2EventCenter.default.postEvent("showButtons");
            console.error(e);
          });
        }
      }
    }
  }, {
    key: "close",
    value: function close() {
      if (this.interstitialAd) {
        this.interstitialAd.offError();
        this.interstitialAd.destroy();
        this.interstitialAd = null;
      }
    }
  }], [{
    key: "Instance",
    get() {
      _o51._instance || (_o51._instance = new _o51());
      return _o51._instance;
    }
  }]);
}();
def_InterstitialMgr = _o51 = cc__decorate([l], def_InterstitialMgr);
exports.default = def_InterstitialMgr;